<%@page import="java.util.Date"%>
<%@page import="web.lbsproject.processaudit.model.DateFormats"%>
<%@page import="lbsproject.processaudit.model.CheckTask"%>
<%@page import="lbsproject.processaudit.model.CheckPoint"%>
<%@page import="web.lbsproject.processaudit.model.CheckTaskDefine4Web"%>
<%@page import="lbsproject.processaudit.model.Worker"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!-- Begin: WEB-INF/template/taskManage/addTask/checkTaskAssign.jsp -->
<!--
<p class="form item">
	<strong>巡检任务委派</strong>
</p> -->
<form class="form" action="AddCheckTaskAssign" method="post">

	<p class="form-item">
	<label class="item-t" for="checkPoint">任务片区：</label> 
	<select id="checkPoint" name="checkPoint">
	
	</select>
	<a href="ShowWorkRegions" class = "text_add">创建新的<span>任务片区</span></a>
	</p>

	<p class="form-item">
	<label class="item-t" for="checkPoint">任务地点：</label> 
	<select id="checkPoint" name="checkPoint">
	<%
	@SuppressWarnings("unchecked")
	List<CheckPoint> checkPoints  = 
		(List<CheckPoint>)request.getAttribute("checkPoints");
	String locationID = (String)request.getAttribute("locationID");
	if (locationID == null) locationID = "";
	if (checkPoints  != null) {
		for (CheckPoint cp: checkPoints) {
			String selected = "";
			if (locationID.equals(cp.getId()))
				selected = "selected=\"selected\"";
	%>
		<option value="<%=cp.getId() %>" <%=selected %>><%=cp.getName() %>(<%=cp.getLocatedRegion().getName() %>)</option>
	<%
		}
	}
	%>
	</select>
	<a href="ShowCheckPoints" class = "text_add">创建新的<span>任务地点</span></a>
	</p>
	
	<p class="form-item">

	<label class="item-t" for="taskType">任务类型：</label> 
	<select id="taskType" name="taskType">
	<%
	@SuppressWarnings("unchecked")
	List<CheckTaskDefine4Web> checkTaskDefines  = 
		(List<CheckTaskDefine4Web>)request.getAttribute("checkTaskDefines");
	if (checkTaskDefines  != null) {
		for (CheckTaskDefine4Web task: checkTaskDefines) {
	%>
		<option value="<%=task.getId()%>"><%=task.getDescription() %></option>
	<%
		}
	}
	%>
	</select>
	<a href="ShowCheckTaskDefines" class = "text_add">创建新的<span>任务类型</span></a>
	</p>
	<!-- 
	<p class="form-item">
		<label class="item-t"  for="exeDate">执行日期：</label>
		<input class="Wdate" onclick="WdatePicker()" size="12" type="text" value="<%=DateFormats.YMD_FORMAT.format(new Date()) %>" name="exeDate" id="exeDate" class="input"/>
	<em></em>
	</p>
	 -->
	 <input type="hidden" value="<%=DateFormats.YMD_FORMAT.format(new Date()) %>">
	 
	<p class="form-item">
		<label class="item-t"  for="exeWorker">执行人员：</label>
		<select id="exeWorker" name="exeWorker">
	<%
	@SuppressWarnings("unchecked")
	List<Worker> allWorkers = (List<Worker>)request.getAttribute("workers");
	if (allWorkers != null) {
		for (Worker w: allWorkers) {
	%>
		<option value="<%=w.getWorkerID()%>"><%=w.getName() %></option>
	<%		
		}
	}
	%>
		</select>
		<a href="ShowWorkers?mode=add" class = "text_add">创建新的<span>人员</span></a>
		
	</p>
	
	<input class ="btn search-btn" type="submit" value="添加任务"/>
</form>

<h1 align="center">&nbsp;已分配任务列表&nbsp; </h1>
<!-- show existed tasks -->

<div class="blank">
	<table class="table">
		<thead>
			<tr>
				<th width="14%">任务地点</th>
				<!-- <th width="14%">执行时间</th> -->
				<th width="10%">执行人</th>
				<th width="14%">任务类型</th>
				<th width="12%">任务状态</th>
				<th width="14%">执行结果</th>
				<th width="10%">委派人</th>
				<th width="14%">委派时间</th>
			</tr>
		</thead>
		<tbody>
		<%
		@SuppressWarnings("unchecked")
		List<CheckTask> checkTasks  = 
			(List<CheckTask>)request.getAttribute("checkTasks");
		if (checkTasks  != null) {
			for (CheckTask t: checkTasks) {
		%>
			<tr>
				<td><%=t.getCheckPoint().getName() %></td>
				<!--<td><%=DateFormats.YMD_FORMAT.format(t.getFinishDate()) %></td>-->
				<td><%=t.getExeWorker().getName() %></td>
				<td><%=t.getName() %></td>
				<td><%=t.getTaskStatus().toChnString() %></td>
				<td><%=t.getExecuteResult().toChnString() %></td>
				<td><%=t.getAssignStaff().getName() %></td>
				<td><%=DateFormats.YMD_FORMAT.format(t.getAssignDate()) %></td>
			</tr>
		<%
			}
		}
		%>
		</tbody>
	</table>
</div>
<!-- End -->